target = test
#由于 .c文件在不同的文件下，那么匹配模式 要匹配不同文件下的%.c文件
zlog = $(wildcard ../common/zlog/*.c)
zlogObj = $(patsubst %.c,%.o,$(zlog))

fal = $(wildcard ../fal/lane_control/*.c)
#include "fal/lane_control.h"
fal := $(filter-out  ../fal/lane_control/pic_save.c ../fal/lane_control/railup_data.c ../fal/lane_control/car_handle.c ../fal/lane_control/lane_control.c, $(fal))
falObj = $(patsubst %.c,%.o,$(fal))
$(info $(fal))

testSrc = $(wildcard ./*.c)
testSrcObj = $(patsubst %.c,%.o,$(testSrc))

src = $(wildcard ../common/*.c)
src := $(filter-out  ../common/comm_tools.c ../common/chedaoji_service.c, $(src))
srcObj = $(patsubst %.c,%.o,$(src))

iPath=-I/home/vmuser/work/chedaoji.bak/include \
-I/home/vmuser/work/chedaoji.bak/include/common \
-I/home/vmuser/work/chedaoji.bak/include/common/zlog \
-I/home/vmuser/work/chedaoji.bak/include/fal

iLd=-lcriterion -lpthread
# iLd=-lpthread 
flag=-g3 -O0 -rdynamic

$(target):$(zlogObj) $(testSrcObj) $(srcObj) $(falObj)
	gcc $^ $(iLd) $(iPath) $(flag) -o $@
#	gcc $(obj) -o $(target)
#-编译 src下的.c文件 为.o文件	
%.o:$(src)%.c
	gcc -c $(flag) $(iLd) $(iPath) $< -o $@
#-编译 当前文件下的main.c文件
%.o:%.c
	gcc -c $(flag) $(iLd) $(iPath) $< -o $@
.PHONY:clean #防止 外面有clean文件 阻止执行clean
clean:
	#-mkdir /root/aaa  #在命令前添加 - 当前命令出错，仍然可以往后面执行
	-rm $(target) $(zlogObj) $(testSrcObj) $(srcObj) -f
hello:
	echo "hello world"